﻿<%@ WebHandler Language="C#" Class="Handler1" %>
using System;
using System.Web;
public class Handler1 : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "application/json";
        var chufa = context.Request["chufa"];
        var daoda = context.Request["daoda"];
        var date = context.Request["riqi"];
        if (string.IsNullOrEmpty(date))
            date = DateTime.Now.ToString("yyyy-MM-dd") ;
        if (string.IsNullOrEmpty(chufa))
            chufa = "NNZ";

        if (string.IsNullOrEmpty(daoda))
            daoda = "NFZ";

        var url = string.Format("https://kyfw.12306.cn/otn/leftTicket/queryZ?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT", date, chufa, daoda);
        context.Response.Write(HttpHelper.Get(url));

    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}
